package com.thinking.dubbo.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName InterceptorConfig
 * @Description TODO
 * @Author tangsixiang@gmail.com
 * @Date 2023/6/5 14:57
 * @Version 1.0
 */
@Configuration
@Slf4j
public class InterceptorConfig  implements WebMvcConfigurer {
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截所有请求
        registry.addInterceptor(globalInterceptor()).addPathPatterns("/**");
        log.info("系统拦截器初始化完成");
    }

    @Bean
    public GlobalInterceptor globalInterceptor() {
        return new GlobalInterceptor();
    }

}
